package com.assignwork.modules.Statistics;

import com.assignwork.dto.DailySafeInfoSubmitDTO;
import com.assignwork.dto.StatisticsSearchDTO;
import com.assignwork.dto.WorkerInfoDTO;
import com.assignwork.service.IStatisticsService;
import com.assignwork.vo.ThroughPutStatisticsVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@RestController
@AllArgsConstructor
@RequestMapping("statistics")
public class StatisticsController {
    private IStatisticsService service;

    @GetMapping("shiftList")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "工班量统计", notes = "工班量统计")
    public R shiftStatisticsList( StatisticsSearchDTO dto) {
        return R.data(service.shiftStatisticsList(dto));
    }

    @GetMapping("throughPutList")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "吞吐量统计", notes = "吞吐量统计")
    public R throughPutList(StatisticsSearchDTO dto, Query query) {
        IPage<ThroughPutStatisticsVO> page = new Page<>(query.getCurrent(), query.getSize(),false);
        return R.data(service.throughPutList(dto, page));
    }

    @GetMapping("berthList")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "泊位", notes = "泊位")
    public R berthList() {
        return R.data(service.berthList());
    }
    @GetMapping("exportthroughput")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "泊位", notes = "泊位")
    public void exportthroughput(HttpServletResponse response, StatisticsSearchDTO dto) {
        service.exportthroughput(response,dto);
    }

    @GetMapping("hmListQuery")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "货名", notes = "货名")
    public R hmListQuery() {
      return   R.data(service.hmlList());
    }
    @GetMapping("ttlhlListQuery")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "吞吐量货类", notes = "吞吐量货类")
    public R ttlhlListQuery(StatisticsSearchDTO dto) {
       return R.data(service.ttlhlList(dto));
    }


    @PostMapping("updateTtlStat")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "吞吐量货类", notes = "吞吐量货类")
    public R updateTtlStat(BladeUser bladeUser, @RequestBody StatisticsSearchDTO dto) {
        service.InUpTtlStat(bladeUser,dto);
        return R.success("操作成功");
    }
    @GetMapping("selectVoyage")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "选择航次", notes = "选择航次")
    public R selectVoyage(StatisticsSearchDTO dto) {
        return R.data(service.selectVoyage(dto));
    }


    @GetMapping("deleteVisa")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "删除", notes = "删除")
    public R deleteVisa(StatisticsSearchDTO dto) {
        service.deleteVisa(dto);
        return R.success("删除成功");
    }
    @GetMapping("trainLoading")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "火车装卸过录表", notes = "")
    public R trainLoading (StatisticsSearchDTO dto) {
        return R.data(service.trainLoading(dto));
    }

    @GetMapping("exportTrainLoadLog")
    @ApiOperationSupport(order = 9)
    @ApiOperation(value = "火车装卸过录表", notes = "")
    public void trainLoadingExport(HttpServletResponse response, StatisticsSearchDTO dto) {
        service.trainLoadingExport(response,dto);
    }

    @GetMapping("workShiftStatisticsExport")
    @ApiOperationSupport(order = 10)
    @ApiOperation(value = "导出火车装卸过录表", notes = "")
    public void workShiftStatistics(HttpServletResponse response, StatisticsSearchDTO dto) {
         service.workShiftStatisticsExport(response,dto);
    }

    @GetMapping("workShiftStatistics")
    @ApiOperationSupport(order = 11)
    @ApiOperation(value = "火车装卸过录表", notes = "")
    public R workShiftStatistics( StatisticsSearchDTO dto) {
        return R.data(service.workShiftStatistics(dto));
    }
    @GetMapping("trainStopTime")
    @ApiOperationSupport(order = 12)
    @ApiOperation(value = "火车停时", notes = "")
    public R trainStopTime( StatisticsSearchDTO dto) {
        return R.data(service.trainStopTime(dto));
    }


    @GetMapping("workLoadStatistic")
    @ApiOperationSupport(order = 12)
    @ApiOperation(value = "工作量查询", notes = "")
    public R workLoadStatistic( StatisticsSearchDTO dto) {
        return R.data(service.workLoadStatistic(dto));
    }


    @GetMapping("workLoadStatisticExport")
    @ApiOperationSupport(order = 12)
    @ApiOperation(value = "工作量查询", notes = "")
    public void workLoadStatisticExport( HttpServletResponse response,StatisticsSearchDTO dto) {
        service.workLoadStatisticExport(response, dto);
    }

}
